﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;
using KPIS.Utils;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.APP.Classes;
using _WebShared.Classes;
using System.IO;
using System.Collections.Generic;
using Telerik.Web.UI;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class DialogDisciplineCommand : System.Web.UI.Page
    {
        private IEmployeeBLL empBLL = new EmployeeBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            IncludeJava();
            if (!IsPostBack)
            {
                    lblETID.Text = Request.QueryString["ETID"].ToString();
              
                    LoadGrid(lblETID.Text);
            }
        }

        private void LoadGrid(string EmpTypeID)
        {

            //Session["id"]
            IList<EmployeeInfo> infoList = empBLL.ListEmployeeByTypes(EmpTypeID, string.Empty, string.Empty);

            RadGrid1.DataSource = infoList;
            RadGrid1.DataBind();

        }

        private void LoadGrid(string EmpTypeID,string JobSiteID)
        {

            //Session["id"]
            IList<EmployeeInfo> infoList = empBLL.ListEmployeeByTypes(EmpTypeID, JobSiteID, string.Empty);

            RadGrid1.DataSource = infoList;
            RadGrid1.DataBind();

        }

        public void IncludeJava()
        {
            HtmlGenericControl script = new HtmlGenericControl();
            script.TagName = "script";
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", "../../Scripts/jsfunction.js");
            Page.Header.Controls.Add(script);
        }
        protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            LoadGrid(lblETID.Text);
        }

        protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            // str = gv_listSearch2.DataKeys(e.Row.RowIndex).Value.ToString() & "|" & e.Row.Cells(2).Text
            //str = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Sequence"].ToString();
            if (e.Item is GridDataItem)  
            {
                GridDataItem item=(GridDataItem)e.Item;  
                string Datakey=item.OwnerTableView.DataKeyValues[item.ItemIndex]["Sequence"].ToString();
                ((LinkButton)e.Item.Cells[2].FindControl("targetControl")).Attributes.Add("OnClick", "windowReturn('" + Datakey + "')");
            }  
        }
    }
}
